home *** CD-ROM | disk | FTP | other *** search
/ Windows Expert / Windows Expert.iso / windownt / uupc11ys.zip / LIB / SETSTDIN.C < prev    next >
C/C++ Source or Header  |  1993-04-10  |  1KB  |  47 lines

  1. /*
  2.  *    $Id: SETSTDIN.C 1.1 1993/04/10 21:22:29 dmwatt Exp $
  3.  *
  4.  *    $Log: SETSTDIN.C $
  5.  * Revision 1.1  1993/04/10  21:22:29  dmwatt
  6.  * Initial revision
  7.  *
  8.  *     Revision 1.1  1993/04/09  06:22:00  dmwatt
  9.  *     Written
  10.  *
  11.  */
  12.  
  13. /*--------------------------------------------------------------------*/
  14. /*                        System include files                        */
  15. /*--------------------------------------------------------------------*/
  16.  
  17. #include <stdio.h>
  18.  
  19. #ifdef WIN32
  20.  
  21. #include <windows.h>
  22.  
  23. /*--------------------------------------------------------------------*/
  24. /*    s e t s t d i n m o d e                                         */
  25. /*                                                                    */
  26. /*    Set standard input on NT console for single char I/O            */
  27. /*--------------------------------------------------------------------*/
  28.  
  29. void setstdinmode(void)
  30. {
  31.    HANDLE hStdIn = GetStdHandle(STD_INPUT_HANDLE);
  32.    DWORD mode;
  33.    BOOL bSuccess;
  34.  
  35.    bSuccess = GetConsoleMode(hStdIn, &mode);
  36.  
  37. /* Disable mouse events so that later Peeks() only get characters */
  38.    mode &= ~ENABLE_WINDOW_INPUT;
  39.    mode &= ~ENABLE_MOUSE_INPUT;
  40.    mode &= ~ENABLE_LINE_INPUT;
  41.    mode |= ENABLE_PROCESSED_INPUT;
  42.  
  43.    SetConsoleMode(hStdIn, mode);
  44. }
  45.  
  46. #endif
  47.